#!/bin/bash

test1 () 
{
        echo ""
        echo "Test 1:"
        java compiler/Compiler ../data/test1.txt ../out/test1.out
}

test2 () 
{
        echo ""
        echo "Test 2:"
        java compiler/Compiler ../data/Test-Aufgabe-1.txt ../out/Test-Aufgabe-1.out
}

test3 () 
{
        echo ""
        echo "Test 3:"
        java compiler/Compiler ../data/myprog.txt ../out/myprog.out
}

test30 ()
{
        echo ""
        echo "Test 3_0: Integer Ops"
        java compiler/Compiler ../data/a3-test0-integer-ops.txt ../out/a3-test0-integer-ops.out
}

test31 ()
{
        echo ""
        echo "Test 3_1: Statements"
        java compiler/Compiler ../data/a3-test1-statements.txt ../out/a3-test1-statements.out
}


test32 ()
{
        echo ""
        echo "Test 3_2: Named Constants"
        java compiler/Compiler ../data/a3-test2-named-constants.txt ../out/a3-test2-named-constants.out
}


test33 ()
{
        echo ""
        echo "Test 3_3: Array"
        java compiler/Compiler ../data/a3-test3-array.txt ../out/a3-test3-array.out
}

test34 ()
{
        echo ""
        echo "Test 3_4: Record"
        java compiler/Compiler ../data/a3-test4-record.txt ../out/a3-test4-record.out
}

test35 ()
{
        echo ""
        echo "Test 3_5: Named Types"
        java compiler/Compiler ../data/a3-test5-named-types.txt ../out/a3-test5-named-types.out
}

test400 ()
{
        echo ""
        echo "Test 4_00:"
        java compiler/Compiler ../data/a4-v08-00.txt ../out/a4-v08-00.out
}

test401 ()
{
        echo ""
        echo "Test 4_01:"
        java compiler/Compiler ../data/a4-v08-01.txt ../out/a4-v08-01.out
}

test4001 ()
{
        echo ""
        echo "Test 4_001:"
        java compiler/Compiler ../data/a4-v08-001.txt ../out/a4-v08-001.out
}
test402 ()
{
        echo ""
        echo "Test 4_02:"
        java compiler/Compiler ../data/a4-v08-02.txt ../out/a4-v08-02.out
}
test403 ()
{
        echo ""
        echo "Test 4_03:"
        java compiler/Compiler ../data/a4-v08-03.txt ../out/a4-v08-03.out
}

if [ -d bin_ ]; then
   rm -R bin_
fi

mkdir bin_
#jflex src/compiler/flex.flex
#javac -d bin_ src/nodes/AbstractNode.java
echo "Start Compiling"
javac -cp bin_ -d bin_ -sourcepath src src/compiler/Compiler.java
echo "Finished Compiling"

cd bin_

case "$1" in
"1")
	test1;;
"2")
	test2;;
"3")
	test3;;
"3_0")
	test30;;
"3_1")
	test31;;
"3_2")
	test32;;
"3_3")
	test33;;
"3_4")
	test34;;
"3_5")
	test35;;
"4_00")
	test400;;
"4_001")
	test4001;;
"4_01")
	test401;;
"4_02")
	test402;;
"4_03")
	test403;;
"ALL")
	test1
	test2
	test3
	test30
	test31
	test32
	test33
	test34
	test35
	test400
	test4001
	test401
	test402
	test403;;
*)
	echo "Testing" $1 
	java compiler/Compiler ../data/$1 ../out/$1
	java -cp ../lib/StdAloneNew.jar cip.standaloneCodeGen.StandaloneCG ../out/$1 $2;;
esac

cd ..
